package com.gxa.jd.controller.front;


import com.gxa.entity.PageResult;
import com.gxa.entity.Result;
import com.gxa.jd.pojo.GoodsOrderItem;
import com.gxa.jd.service.GoodsOrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/orderItem")
public class GoodsOrderItemController {

    @Autowired
    private GoodsOrderItemService goodsOrderItemService;

    @GetMapping("/findAll")
    public List<GoodsOrderItem> findAll(){
        return goodsOrderItemService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<GoodsOrderItem> findPage(int page, int size){
        return goodsOrderItemService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<GoodsOrderItem> findList(@RequestBody Map<String,Object> searchMap){
        return goodsOrderItemService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<GoodsOrderItem> findPage(@RequestBody Map<String,Object> searchMap, int page, int size){
        return  goodsOrderItemService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public GoodsOrderItem findById(Long id){
        return goodsOrderItemService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody GoodsOrderItem goodsOrderItem){
        goodsOrderItemService.add(goodsOrderItem);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody GoodsOrderItem goodsOrderItem){
        goodsOrderItemService.update(goodsOrderItem);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        goodsOrderItemService.delete(id);
        return new Result();
    }

}
